#include "AccountManagerInstance.h"

AccountManagerInstance::AccountManagerInstance(): reference(0)
{
	IncreaseReference();
}

AccountManagerInstance::~AccountManagerInstance()
{
}

void AccountManagerInstance::AddAccount(const Account& account)
{
	accounts.push_back(account);
}


int AccountManagerInstance::GetReferenceCount() const
{
	return reference;
}

void AccountManagerInstance::IncreaseReference()
{
	reference++;
}

void AccountManagerInstance::DecreaseReference()
{
	reference--;
}

const Account* AccountManagerInstance::GetAccount(const std::string& username) const
{
	std::list<Account>::const_iterator it;

	for(it = accounts.begin(); it != accounts.end(); ++it)
	{
		const Account& account = *it;

		if (account.Username() == username)
			return &account;
	}

	return 0;
}


